/*
 * 	Additional function for tables.html
 *	Written by ThemePixels	
 *	http://themepixels.com/
 *
 *	Copyright (c) 2012 ThemePixels (http://themepixels.com)
 *	
 *	Built for Amanda Premium Responsive Admin Template
 *  http://themeforest.net/category/site-templates/admin-templates
 */

jQuery(document).ready(function(){
	jQuery('#salaryRecordTable').dataTable({
		"sPaginationType": "full_numbers",
		"oLanguage": {
			"sLengthMenu": "每页显示 _MENU_ 条记录",
			"sZeroRecords": "抱歉， 没有找到",
			"sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
			"sInfoEmpty": "没有数据",
			"sInfoFiltered": "(从 _MAX_ 条数据中检索)",
			"sSearch":"全文搜索:",
			"oPaginate": {
			"sFirst": "首页",
			"sPrevious": "前一页",
			"sNext": "后一页",
			"sLast": "尾页",
			},
			"sZeroRecords": "没有检索到数据",
			"sProcessing": "<img src='./loading.gif' />"
		}
	});
	
	jQuery("#print").click(function(){
		jQuery("div#salaryRecordDetail").printArea();  
	});
	
});

function showEditDialog(id,empName){
	jQuery.ajax({
		url:'/salaryRecord/recordInfo',
		type:'POST',
		async:true,
		data:{
			id:id
		},
		dataType:'json',
		success:function(data){
			if(data.result.status == "success") {
				var record = data.result.record;
				jQuery('#emp').html(empName);
				jQuery('#recordTime').html(record.recordTime);
				jQuery('#basicSalary').html("￥" + record.basicSalary);
				jQuery('#endowmentMoney').html("￥" + record.endowmentMoney);
				jQuery('#medicareMoney').html("￥" + record.medicareMoney);
				jQuery('#injuryMoney').html("￥" + record.injuryMoney);
				jQuery('#birthMoney').html("￥" + record.birthMoney);
				jQuery('#housingMoney').html("￥" + record.housingMoney);
				jQuery('#unemploymentMoney').html("￥" + record.unemploymentMoney);
				jQuery('#travelMoney').html("￥" + record.travelMoney);
				jQuery('#extraWorkMoney').html("￥" + record.extraWorkMoney);
				jQuery('#leaveMoney').html("￥" + record.leaveMoney);
				jQuery('#lateMoney').html("￥" + record.lateMoney);
				jQuery('#neglectWorkMoney').html("￥" + record.neglectWorkMoney);
				jQuery('#bonus').html("￥" + record.bonus);
				jQuery('#totalMoney').html("总金额:￥" + record.totalMoney);
				jQuery("#salaryRecordDetail").dialog({
					 width:600,
				});
			} else {
				alert("内部错误");
			}
		}
	});
};